<template>
    <div class="content">
        <div class="card_header">

        </div>

        <div class="card_list">

            <div class="card_header_button">
                <a-button type="primary">新增</a-button>
                <a-button type="primary">删除</a-button>
            </div>

            <a-table :columns="columns" :data="data" :loading="loading">
                <template #bodyCell="{ column, record }">
                    <template v-if="column.dataIndex === 'action'">
                        <a-button type="primary">编辑</a-button>
                    </template>
                </template>
            </a-table>
        </div>
    </div>
</template>

<script setup>
import { onMounted, ref } from 'vue';
import { getPostList } from '@/api/post'

const columns = ref([
    { title: 'ID', dataIndex: 'postId' },
    { title: '标题',dataIndex: 'postTitle'}, 
    { title: '所属贴吧',dataIndex: 'forumName'}, 
    { title: '用户昵称',dataIndex: 'user.nickname'},
    { title: '帖子类别',dataIndex: 'category'},
    { title: '发帖时间',dataIndex: 'createTime'}
]);

const data = ref(null);
const loading = ref(false);

function getList(){
    loading.value = true;
    getPostList().then(res => {
        data.value = res.data
        loading.value = false;
        console.log(res);
    })
}

onMounted(() => {
    getList();
});

</script>

<style scoped></style>